import cv2
import numpy as np
from matplotlib import pyplot as plt


# img1 = cv2.imdecode(np.fromfile(r'C:\Users\刘翼\Desktop\Figure\93b5aba35c648ff18e0534dfed103278_.png', dtype=np.uint8), -1)
# img2 = cv2.imdecode(np.fromfile(r'C:\Users\刘翼\Desktop\Figure\fff3618e27a2a2d6225484f6c16d0e9b_.png', dtype=np.uint8), -1)

# img3 = cv2.add(img1,img2)   #cv2.add函数

# img3 = cv2.subtract(img1,img2)   #cv2.subtract函数

# img3 = cv2.multiply(img1, img2) #cv2.multiply进行矩阵点乘

# img3 = cv2.divide(img1,img2) #cv2.divide()矩阵点除

img1 = cv2.imread(r'C:\Users\Public\opencv\Figure\24e735b1892a1f730c791f4cd5413355_.png')
img2 = cv2.imread(r'C:\Users\Public\opencv\Figure\4e4717eb775d4610c9baa25446d476fd_.png')


# img3 = cv2.bitwise_and(img1, img2) # 与

# img3 = cv2.bitwise_or(img1, img2) # 或

# img3 = cv2.bitwise_xor(img1, img2)  #异或

img3 = cv2.bitwise_not(img1) # 对img1非
img4 = cv2.bitwise_not(img2) # 对img2非

# plt.subplot(131),plt.imshow(img1)
# plt.subplot(132),plt.imshow(img2)
# plt.subplot(133),plt.imshow(img3)

plt.subplot(141),plt.imshow(img1)
plt.subplot(142),plt.imshow(img2)
plt.subplot(143),plt.imshow(img3)
plt.subplot(144),plt.imshow(img4)

cv2.waitKey(0)
cv2.destroyAllWindows()

